<template>
  <div class="app-container">
    <!-- 账单统计卡片 -->
    <el-row :gutter="20" class="mb8">
      <el-col :span="6">
        <el-card class="box-card">
          <div class="card-header">
            <span>应收总额</span>
          </div>
          <div class="card-content">
            <span class="amount-text">¥{{ statistics.totalAmount || 0 }}</span>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card class="box-card">
          <div class="card-header">
            <span>已收金额</span>
          </div>
          <div class="card-content">
            <span class="amount-text success">¥{{ statistics.paidAmount || 0 }}</span>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card class="box-card">
          <div class="card-header">
            <span>未收金额</span>
          </div>
          <div class="card-content">
            <span class="amount-text danger">¥{{ statistics.unpaidAmount || 0 }}</span>
          </div>
        </el-card>
      </el-col>
      <el-col :span="6">
        <el-card class="box-card">
          <div class="card-header">
            <span>逾期账单</span>
          </div>
          <div class="card-content">
            <span class="amount-text warning">{{ statistics.overdueBillCount || 0 }}笔</span>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="账单编号" prop="billNo">
        <el-input
          v-model="queryParams.billNo"
          placeholder="请输入账单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名称" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入客户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="支付状态" prop="paymentStatus">
        <el-select v-model="queryParams.paymentStatus" placeholder="请选择支付状态" clearable>
          <el-option label="未支付" value="未支付" />
          <el-option label="部分支付" value="部分支付" />
          <el-option label="已逾期" value="已逾期" />
          <el-option label="已支付" value="已支付" />
        </el-select>
      </el-form-item>
      <el-form-item label="账单周期" prop="billPeriod">
        <el-date-picker
          v-model="billPeriod"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleGenerate"
          v-hasPermi="['veterinary:bill:add']"
        >生成账单</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['veterinary:bill:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['veterinary:bill:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['veterinary:bill:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-warning"
          size="mini"
          @click="handleUnpaid"
        >未付账单</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="billList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="账单编号" align="center" prop="billNo" />
      <el-table-column label="客户名称" align="center" prop="customerName" :show-overflow-tooltip="true" />
      <el-table-column label="账单周期" align="center" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.billPeriodStart, '{y}-{m}-{d}') }} 至 {{ parseTime(scope.row.billPeriodEnd, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="总金额" align="center" prop="totalAmount">
        <template slot-scope="scope">
          <span>¥{{ parseFloat(scope.row.totalAmount).toFixed(2) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="已付金额" align="center" prop="paidAmount">
        <template slot-scope="scope">
          <span class="text-success">¥{{ parseFloat(scope.row.paidAmount).toFixed(2) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="未付金额" align="center" prop="unpaidAmount">
        <template slot-scope="scope">
          <span :class="scope.row.unpaidAmount > 0 ? 'text-danger' : 'text-success'">
            ¥{{ parseFloat(scope.row.unpaidAmount).toFixed(2) }}
          </span>
        </template>
      </el-table-column>
      <el-table-column label="交易笔数" align="center" prop="transactionCount" />
      <el-table-column label="支付状态" align="center" prop="paymentStatus">
        <template slot-scope="scope">
          <el-tag 
            :type="getPaymentStatusType(scope.row.paymentStatus)"
          >
            {{ scope.row.paymentStatus }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="最早欠款日期" align="center" prop="earliestDebtDate" width="120">
        <template slot-scope="scope">
          <span v-if="scope.row.earliestDebtDate">{{ parseTime(scope.row.earliestDebtDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleDetail(scope.row)"
          >详情</el-button>
          <el-button
            v-if="scope.row.unpaidAmount > 0"
            size="mini"
            type="text"
            icon="el-icon-money"
            @click="handlePayment(scope.row)"
            v-hasPermi="['veterinary:bill:edit']"
          >收款</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['veterinary:bill:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['veterinary:bill:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 生成账单对话框 -->
    <el-dialog title="生成客户账单" :visible.sync="generateOpen" width="500px" append-to-body>
      <el-form ref="generateForm" :model="generateForm" :rules="generateRules" label-width="100px">
        <el-form-item label="客户" prop="customerId">
          <el-select v-model="generateForm.customerId" placeholder="请选择客户" filterable>
            <el-option
              v-for="customer in customerList"
              :key="customer.customerId"
              :label="customer.customerName"
              :value="customer.customerId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="账单周期" prop="billPeriod">
          <el-date-picker
            v-model="generateForm.billPeriod"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitGenerate">确 定</el-button>
        <el-button @click="generateOpen = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 收款对话框 -->
    <el-dialog title="收款记录" :visible.sync="paymentOpen" width="400px" append-to-body>
      <el-form ref="paymentForm" :model="paymentForm" :rules="paymentRules" label-width="100px">
        <el-form-item label="账单编号">
          <el-input v-model="paymentForm.billNo" readonly />
        </el-form-item>
        <el-form-item label="客户名称">
          <el-input v-model="paymentForm.customerName" readonly />
        </el-form-item>
        <el-form-item label="未付金额">
          <el-input v-model="paymentForm.unpaidAmount" readonly />
        </el-form-item>
        <el-form-item label="收款金额" prop="paidAmount">
          <el-input-number v-model="paymentForm.paidAmount" :precision="2" :step="0.01" :min="0.01" :max="paymentForm.unpaidAmount" placeholder="请输入收款金额" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitPayment">确 定</el-button>
        <el-button @click="paymentOpen = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 账单详情对话框 -->
    <el-dialog title="账单详情" :visible.sync="detailOpen" width="1000px" append-to-body>
      <el-descriptions :column="3" border>
        <el-descriptions-item label="账单编号">{{ billDetail.billNo }}</el-descriptions-item>
        <el-descriptions-item label="客户名称">{{ billDetail.customerName }}</el-descriptions-item>
        <el-descriptions-item label="支付状态">
          <el-tag :type="getPaymentStatusType(billDetail.paymentStatus)">{{ billDetail.paymentStatus }}</el-tag>
        </el-descriptions-item>
        <el-descriptions-item label="账单周期">
          {{ parseTime(billDetail.billPeriodStart, '{y}-{m}-{d}') }} 至 {{ parseTime(billDetail.billPeriodEnd, '{y}-{m}-{d}') }}
        </el-descriptions-item>
        <el-descriptions-item label="总金额">¥{{ parseFloat(billDetail.totalAmount || 0).toFixed(2) }}</el-descriptions-item>
        <el-descriptions-item label="已付金额">¥{{ parseFloat(billDetail.paidAmount || 0).toFixed(2) }}</el-descriptions-item>
        <el-descriptions-item label="未付金额">¥{{ parseFloat(billDetail.unpaidAmount || 0).toFixed(2) }}</el-descriptions-item>
        <el-descriptions-item label="交易笔数">{{ billDetail.transactionCount }}</el-descriptions-item>
        <el-descriptions-item label="最早欠款日期">{{ parseTime(billDetail.earliestDebtDate, '{y}-{m}-{d}') }}</el-descriptions-item>
      </el-descriptions>
      
      <el-divider content-position="left">账单明细</el-divider>
      
      <!-- 账单明细搜索区域 -->
      <el-form :model="detailQueryParams" ref="detailQueryForm" size="small" :inline="true" class="mb8">
        <el-form-item label="出货单号" prop="outboundOrderNo">
          <el-input
            v-model="detailQueryParams.outboundOrderNo"
            placeholder="请输入出货单号"
            clearable
            @keyup.enter.native="handleDetailQuery"
          />
        </el-form-item>
        <el-form-item label="药品名称" prop="drugName">
          <el-input
            v-model="detailQueryParams.drugName"
            placeholder="请输入药品名称"
            clearable
            @keyup.enter.native="handleDetailQuery"
          />
        </el-form-item>
        <el-form-item label="出货日期" prop="outboundDate">
          <el-date-picker
            v-model="detailQueryParams.outboundDate"
            type="date"
            placeholder="选择出货日期"
            value-format="yyyy-MM-dd">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleDetailQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetDetailQuery">重置</el-button>
        </el-form-item>
      </el-form>
      
      <!-- 账单明细表格 -->
      <el-table 
        v-loading="detailLoading" 
        :data="billDetailList" 
        style="width: 100%"
        :header-cell-style="{background:'#f8f8f9', color:'#606266'}"
        border
        v-if="billDetailList && billDetailList.length > 0"
      >
        <el-table-column label="出货日期" prop="outboundDate" width="120">
          <template slot-scope="scope">
            {{ parseTime(scope.row.outboundDate, '{y}-{m}-{d}') }}
          </template>
        </el-table-column>
        <el-table-column label="出货单号" prop="outboundOrderNo" width="150" />
        <el-table-column label="兽药名称" prop="drugName" :show-overflow-tooltip="true" />
        <el-table-column label="规格" prop="drugSpecification" width="120" />
        <el-table-column label="数量" prop="quantity" width="80" align="center" />
        <el-table-column label="单价" prop="unitPrice" width="100" align="right">
          <template slot-scope="scope">
            ¥{{ parseFloat(scope.row.unitPrice).toFixed(2) }}
          </template>
        </el-table-column>
        <el-table-column label="金额" prop="amount" width="120" align="right">
          <template slot-scope="scope">
            ¥{{ parseFloat(scope.row.amount).toFixed(2) }}
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="120">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-view"
              @click="handleViewOutbound(scope.row)"
            >查看出货</el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <!-- 无数据提示 -->
      <div v-else class="empty-block">
        <el-empty description="暂无账单明细数据"></el-empty>
      </div>
      
      <!-- 账单明细分页 -->
      <pagination
        v-show="detailTotal>0"
        :total="detailTotal"
        :page.sync="detailQueryParams.pageNum"
        :limit.sync="detailQueryParams.pageSize"
        @pagination="getBillDetailList"
      />
    </el-dialog>

    <!-- 未付账单对话框 -->
    <el-dialog title="累计未支付账单" :visible.sync="unpaidOpen" width="1200px" append-to-body>
      <el-table :data="unpaidList" style="width: 100%">
        <el-table-column label="客户名称" prop="customerName" />
        <el-table-column label="累计未付金额" prop="unpaidAmount">
          <template slot-scope="scope">
            <span class="text-danger">¥{{ parseFloat(scope.row.unpaidAmount).toFixed(2) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="欠款笔数" prop="transactionCount" />
        <el-table-column label="最早欠款日期" prop="earliestDebtDate">
          <template slot-scope="scope">
            {{ parseTime(scope.row.earliestDebtDate, '{y}-{m}-{d}') }}
          </template>
        </el-table-column>
        <el-table-column label="支付状态" prop="paymentStatus">
          <template slot-scope="scope">
            <el-tag :type="getPaymentStatusType(scope.row.paymentStatus)">{{ scope.row.paymentStatus }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="催收记录" prop="collectionRecords" :show-overflow-tooltip="true" />
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              @click="handlePayment(scope.row)"
            >收款</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import { listBill, getBill, delBill, addBill, updateBill, getUnpaidList, getStatistics, generateCustomerBill, updatePaymentStatus } from "@/api/veterinary/bill";
import { listCustomer } from "@/api/veterinary/customer";
import { getBillDetailsByBillId } from "@/api/veterinary/billDetail";

export default {
  name: "Bill",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 账单管理表格数据
      billList: [],
      // 未付账单列表
      unpaidList: [],
      // 客户列表
      customerList: [],
      // 账单统计
      statistics: {},
      // 账单详情
      billDetail: {},
      // 账单明细列表
      billDetailList: [],
      // 账单明细总条数
      detailTotal: 0,
      // 账单明细加载状态
      detailLoading: false,
      // 账单明细查询参数
      detailQueryParams: {
        pageNum: 1,
        pageSize: 10,
        billId: null,
        outboundOrderNo: null,
        drugName: null,
        outboundDate: null
      },
      // 账单周期
      billPeriod: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示生成账单对话框
      generateOpen: false,
      // 是否显示收款对话框
      paymentOpen: false,
      // 是否显示详情对话框
      detailOpen: false,
      // 是否显示未付账单对话框
      unpaidOpen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        billNo: null,
        customerId: null,
        customerName: null,
        billPeriodStart: null,
        billPeriodEnd: null,
        paymentStatus: null,
      },
      // 表单参数
      form: {},
      // 生成账单表单
      generateForm: {},
      // 收款表单
      paymentForm: {},
      // 表单校验
      rules: {},
      // 生成账单校验
      generateRules: {
        customerId: [
          { required: true, message: "客户不能为空", trigger: "change" }
        ],
        billPeriod: [
          { required: true, message: "账单周期不能为空", trigger: "change" }
        ]
      },
      // 收款校验
      paymentRules: {
        paidAmount: [
          { required: true, message: "收款金额不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
    this.getCustomerList();
    this.getStatisticsData();
  },
  methods: {
    /** 查询账单管理列表 */
    getList() {
      this.loading = true;
      // 处理账单周期查询参数
      if (this.billPeriod && this.billPeriod.length === 2) {
        this.queryParams.billPeriodStart = this.billPeriod[0];
        this.queryParams.billPeriodEnd = this.billPeriod[1];
      } else {
        this.queryParams.billPeriodStart = null;
        this.queryParams.billPeriodEnd = null;
      }
      
      listBill(this.queryParams).then(response => {
        this.billList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 获取客户列表 */
    getCustomerList() {
      listCustomer({}).then(response => {
        this.customerList = response.rows;
      });
    },
    /** 获取统计数据 */
    getStatisticsData() {
      getStatistics().then(response => {
        this.statistics = response.data;
      });
    },
    /** 获取支付状态标签类型 */
    getPaymentStatusType(status) {
      const statusMap = {
        '未支付': 'info',
        '部分支付': 'warning',
        '已逾期': 'danger',
        '已支付': 'success'
      };
      return statusMap[status] || 'info';
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        billId: null,
        billNo: null,
        customerId: null,
        customerName: null,
        billPeriodStart: null,
        billPeriodEnd: null,
        totalAmount: null,
        paidAmount: null,
        unpaidAmount: null,
        transactionCount: null,
        paymentStatus: null,
        dueDate: null,
        earliestDebtDate: null,
        collectionRecords: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.billPeriod = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.billId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 生成账单按钮操作 */
    handleGenerate() {
      this.generateForm = {
        customerId: null,
        billPeriod: []
      };
      this.generateOpen = true;
    },
    /** 提交生成账单 */
    submitGenerate() {
      this.$refs["generateForm"].validate(valid => {
        if (valid) {
          const params = {
            customerId: this.generateForm.customerId,
            billPeriodStart: this.generateForm.billPeriod[0],
            billPeriodEnd: this.generateForm.billPeriod[1]
          };
          generateCustomerBill(params.customerId, params.billPeriodStart, params.billPeriodEnd).then(response => {
            this.$modal.msgSuccess("账单生成成功");
            this.generateOpen = false;
            this.getList();
            this.getStatisticsData();
          });
        }
      });
    },
    /** 收款按钮操作 */
    handlePayment(row) {
      this.paymentForm = {
        billId: row.billId,
        billNo: row.billNo,
        customerName: row.customerName,
        unpaidAmount: parseFloat(row.unpaidAmount).toFixed(2),
        paidAmount: null
      };
      this.paymentOpen = true;
    },
    /** 提交收款 */
    submitPayment() {
      this.$refs["paymentForm"].validate(valid => {
        if (valid) {
          updatePaymentStatus(this.paymentForm.billId, this.paymentForm.paidAmount).then(response => {
            this.$modal.msgSuccess("收款成功");
            this.paymentOpen = false;
            this.getList();
            this.getStatisticsData();
          });
        }
      });
    },
    /** 详情按钮操作 */
    handleDetail(row) {
      getBill(row.billId).then(response => {
        this.billDetail = response.data;
        this.detailOpen = true;
        // 重置账单明细查询参数
        this.detailQueryParams = {
          pageNum: 1,
          pageSize: 10,
          billId: row.billId,
          outboundOrderNo: null,
          drugName: null,
          outboundDate: null
        };
        // 获取账单明细列表
        this.getBillDetailList();
      });
    },
    
    /** 获取账单明细列表 */
    getBillDetailList() {
      this.detailLoading = true;
      
      // 首先尝试使用账单详情中的明细列表
      if (this.billDetail && this.billDetail.billDetailList && this.billDetail.billDetailList.length > 0) {
        this.billDetailList = this.billDetail.billDetailList;
        this.detailTotal = this.billDetail.billDetailList.length;
        this.detailLoading = false;
        return;
      }
      
      // 如果账单详情中没有明细列表，则调用API获取
      getBillDetailsByBillId(this.detailQueryParams.billId).then(response => {
        if (response.data && Array.isArray(response.data)) {
          this.billDetailList = response.data;
          this.detailTotal = response.data.length;
        } else {
          // 如果后端返回的不是数组，可能是分页对象
          this.billDetailList = response.rows || [];
          this.detailTotal = response.total || 0;
        }
        this.detailLoading = false;
      }).catch(() => {
        this.$message.error("获取账单明细失败");
        this.billDetailList = [];
        this.detailTotal = 0;
        this.detailLoading = false;
      });
    },
    
    /** 账单明细搜索按钮操作 */
    handleDetailQuery() {
      this.detailQueryParams.pageNum = 1;
      this.getBillDetailList();
    },
    
    /** 账单明细重置按钮操作 */
    resetDetailQuery() {
      this.detailQueryParams = {
        pageNum: 1,
        pageSize: 10,
        billId: this.detailQueryParams.billId,
        outboundOrderNo: null,
        drugName: null,
        outboundDate: null
      };
      this.handleDetailQuery();
    },
    
    /** 查看出货记录按钮操作 */
    handleViewOutbound(row) {
      // 这里可以跳转到出货记录详情页面，或者打开出货记录详情弹窗
      this.$modal.msgInfo("查看出货记录：" + row.outboundOrderNo);
      // 如果需要跳转到出货记录详情页面，可以使用以下代码
      // this.$router.push({ path: '/veterinary/outbound/detail', query: { outboundId: row.outboundId } });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const billId = row.billId || this.ids
      getBill(billId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改账单信息";
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const billIds = row.billId || this.ids;
      this.$modal.confirm('是否确认删除账单编号为"' + (row.billNo || billIds) + '"的数据项？').then(function() {
        return delBill(billIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('veterinary/bill/export', {
        ...this.queryParams
      }, `bill_${new Date().getTime()}.xlsx`)
    },
    /** 未付账单按钮操作 */
    handleUnpaid() {
      getUnpaidList().then(response => {
        this.unpaidList = response.data;
        this.unpaidOpen = true;
      });
    }
  }
};
</script>

<style scoped>
.box-card {
  margin-bottom: 20px;
}
.card-header {
  font-size: 14px;
  color: #909399;
  margin-bottom: 10px;
}
.card-content {
  font-size: 24px;
  font-weight: bold;
}
.amount-text {
  color: #303133;
}
.amount-text.success {
  color: #67c23a;
}
.amount-text.danger {
  color: #f56c6c;
}
.amount-text.warning {
  color: #e6a23c;
}
.text-success {
  color: #67c23a;
}
.text-danger {
  color: #f56c6c;
}
.mb8 {
  margin-bottom: 8px;
}
</style>
